//
//  TestConcurrecesApp.swift
//  TestConcurreces
//
//  Created by rolodestar on 2025/6/16.
//

import SwiftUI
import SwiftData
import RoSwiftDataForNetVideoDownload
import BilibiliSearch


@main
struct TestConcurrecesApp: App {
    var sharedModelContainer: ModelContainer = {
        let schema = Schema([
            Item.self,
            BeautyModel.self,
            BilibiliNetVideo.self,
            BilibiliVideoModel.self,
//            BilibiliVideoModel.self,
        ])
        let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)

        do {
            return try ModelContainer(for: schema, configurations: [modelConfiguration])
        } catch {
            fatalError("Could not create ModelContainer: \(error)")
        }
    }()
    
    var videoActor: VideoActor = {
        let schema = Schema([
            Item.self,
            BeautyModel.self,
            BilibiliNetVideo.self,
            BilibiliVideoModel.self,
           
//            BilibiliVideoModel.self,
        ])
        let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)

        do {
            let container =  try ModelContainer(for: schema, configurations: [modelConfiguration])
            return VideoActor(modelContainer: container)
        } catch {
            fatalError("Could not create ModelContainer: \(error)")
        }
    }()

    var body: some Scene {
        WindowGroup {
//            ContentView()
            VideoManView()
        }
        .modelContainer(sharedModelContainer)
        .environmentObject(videoActor)
    }
}
